<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/rp/common/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>">
    
    <title>${ webpageTitle }</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	
	<script src="rp/scripts/boot.js" type="text/javascript"></script>
	
	<style type="text/css">
	   	
    </style>
	
  </head>
  
  <body class="body-p5">
  	
  	<form id="taskForm" method="post">
  		<fieldset>
  			<legend>任务明细</legend>
  			<table style="width: 100%;">
  				<tr>
  					<td style="width: 80px;">任务名称：</td>
  					<td><input id="taskName" name="taskName" class="mini-textbox" required="true" style="width: 300px;"/> <a href="javascript:;" onclick="createGuid();">生成GUID</a></td>
  					<td style="width: 120px;">任务类全路径类名：</td>
  					<td><input id="" name="jobClass" class="mini-textbox" emptyText="必须输入的是全路径类名" required="true" style="width: 300px;"/></td>
  				</tr>
  			</table>
  		</fieldset>
  		
  		<fieldset>
  			<legend>周期定时</legend>
  			<table style="width:100%;">
  				<tr>
  					<td style="width: 80px;">开始时间：</td>
  					<td>
  						<input id="startTime" name="startTime" class="mini-datepicker" style="width:200px;" onvaluechanged="onValueChanged" nullValue="null"
        					required="true" format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" showOkButton="true" showClearButton="false"
        					allowInput="false"/>
        			</td>
  					<td style="width: 80px;">结束时间：</td>
  					<td>
  						<input id="endTime" name="endTime" class="mini-datepicker" style="width:200px;" onvaluechanged="onValueChanged" nullValue="null"
        					required="true" format="yyyy-MM-dd" showTime="false" showOkButton="true" showClearButton="false"
        					allowInput="false" showTodayButton="false" ondrawdate="onDrawDate"/>
  					</td>
  					<td style="width: 80px;">间隔时间：</td>
  					<td>
  						<input id="" name="intervalTime" changeOnMousewheel="false" class="mini-spinner" 
  							minValue="1" maxValue="1440" increment="1" style="width: 60px;"/>
  						<span>分钟</span>
  					</td>
  				</tr>
  			</table>
  			<!-- <table style="width:100%;">
  				<tr>
  					<td style="width: 80px;">重复次数：</td>
  					<td>
  						<input id="" name="repeatCount" changeOnMousewheel="false" class="mini-spinner" minValue="-1" maxValue=""/>
        			</td>
  					
  				</tr>
  			</table> -->
  		</fieldset>
  		
  		<table style="width: 100%;">
  			<tr>
  				<td><a class="mini-button" onclick="submitForm();"><i class="fa fa-floppy-o fa-lg"></i> 保存</a></td>
  				<td></td>
  			</tr>
  		</table>
  	</form>
  	
	<script type="text/javascript">
		$(function(){
			
		});
		
		function createGuid(){
			var taskNameInput = mini.get("taskName");
			rp_ajax("rp/system/common/createGuid",{},function(text){
				taskNameInput.setValue(text);
			});
		}
		
		function submitForm(){
			
			var form = new mini.Form("#taskForm");
			
			form.validate();
            if (form.isValid() == false) return;
            
          	//提交表单数据            
            var data = form.getData();      //获取表单多个控件的数据
            var json = mini.encode(data);   //序列化成JSON
            //mini.alert(json);
            rp_ajax("rp/system/taskMng/addTask", {json: json}, function(text){
            	if(text == "success"){
            		mini.alert("保存成功");
            	}else{
            		mini.alert(text);
            	}
            });
		}
		
		////////////////////////////
        function onDrawDate(e) {
            var date = e.date;
            var d = new Date();

            if (date.getTime() < d.getTime()) {
                e.allowSelect = false;
            }
        }
	</script>
  </body>
</html>
